package com.bosssoft.springcloud.controller;

import com.bosssoft.springcloud.entities.CommenResult;
import com.bosssoft.springcloud.entities.Payment;
import com.bosssoft.springcloud.service.PaymentFeignService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class OrderFeignController {
    @Resource
    private PaymentFeignService paymentFeignService;

    /***
     * 查询订单列表
     * @return 订单列表
     */
    @RequestMapping("/payment/listAll")
    public CommenResult getOrderList(){
        return paymentFeignService.getOrderList();
    }

    /***
     * 通过id查找订单
     * @param id 商品（订单）id
     * @return 订单
     */
    @RequestMapping ("/consumer/payment/get/{id}")
    public CommenResult<Payment> getPaymentById(@PathVariable("id") long  id){

        return  paymentFeignService.getPayentById(id);
    }


    /***
     * 添加订单
     * @param payment 订单
     * @return
     */
    @RequestMapping("/payment/create")
    public  CommenResult create(@RequestBody Payment payment){

       return paymentFeignService.create(payment);
    }

    /***
     * 根据id删除订单
     * @param id
     */
    @RequestMapping  ("/payment/remove/{id}")
    CommenResult removeById(@PathVariable("id") long id){

        return  paymentFeignService.removeById(id);
    }

}
